const { spawn } = require('child_process')
const nodeVersion = process.version
const abortController = new AbortController()

process.env.NODE_OPTIONS = nodeVersion.startsWith('v18')
  ? '--openssl-legacy-provider'
  : ''
const cmd = ['vue-cli-service', ['serve']]
console.log(`$ ${cmd[0]} ${cmd[1].join(' ')}`)
spawn(cmd[0], cmd[1], { stdio: 'inherit', signal: abortController.signal })
const abort = () => {
  abortController.abort()
}
process.on('SIGTERM', abort)
process.on('exit', abort)
